app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){

	$scope.bindBtn = function(event) {
		var datas = $scope.getSelectedRows();
		switch(event){
		case 'event-to-up':
		{
			if(datas.length == 0) {
				layer.alert('尚未选中数据');
			} else {
				var bids = '';
				for(var i = 0 ;i < datas.length; i++){
					bids += datas[i].bid + ',';
				}
				layer.confirm('确定要生成质检上架单？', { icon: 3 }, function() {
					layer.msg('处理中', { icon: 16, shade: 0.01 });
					$http.post('/api/inter/tccAssemble/batchPass', {}, {params: {bids: bids.substring(0, bids.length - 1)}})
					.success(function (res) {
						layer.msg(res.msg);
						setTimeout(function(){
							location.reload();
						}, 1000);
					});
				}, function() {
				});
			}
			break;
		}
		case 'event-to-exception': {
			if (datas.length == 0) {
				layer.alert('尚未选中数据');
			} else if (datas.length > 1) {
				layer.alert('只能选中一行数据');
			} else {
				$scope.showModalLink('/web/storage/tccAssemble/toError?bid=' + datas[0].bid, '流程跟踪');
			}
			break; 
		}
		};
	}
}